<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:bs="http://none.cz">
<head th:include="common/layout::header"></head>
<body>
	<div th:substituteby="common/layout::menu"></div>
	
	<div class="container">
		<div th:include="common/layout::messages">
			cannot load messages
		</div>
		
		<h1 th:text="#{user-list.h1}">List of users</h1>
		<a th:href="@{/admin/user/add}" th:text="#{user-list.add}" href="#" class="btn btn-primary">Add new User</a>
		<table class="table table-striped">
			<thead>
			<tr>
				<th>#</th>
				<th th:text="#{user-list.table.email}">User email</th>
				<th th:text="#{user-list.table.name}">Name</th>
				<th th:text="#{user-list.table.surname}">Surname</th>
				<th th:text="#{user-list.table.role}">Role</th>
				<th th:text="#{user-list.table.active}">Active</th>
				<th th:text="#{user-list.table.locked}">locked</th>
				<th th:text="#{user-list.table.edit}">Edit</th>
				<th th:text="#{user-list.table.delete}">Delete</th>
			</tr>
			</thead>
			<tbody>
				<tr th:each="user,status : ${users}">
					<td th:text="${status.count}">1</td>
					<td th:text="${user.email}">a@a.cz</td>
					<td th:text="${user.name}">name</td>
					<td th:text="${user.surname}">surname</td>
					<td th:text="${user.role}">ADMIN</td>
					<td th:text="(${user.active}? #{user-list.table.active} : #{user-list.table.nonactive})">active</td>
					<td th:text="(${user.locked}? #{user-list.table.locked} : #{user-list.table.unlocked})">active</td>
					<td><a th:href="@{'/admin/user/edit/' + ${user.id}}" href="#" class="btn btn-mini btn-warning">Edit</a></td>
					<td><a th:href="@{'/admin/user/del/' + ${user.id}}" href="#" class="btn btn-mini btn-danger delete-confirm"
					th:onclick="'return confirm(\'' + #{user-list.delete(${user.email})} + '\', \'' + @{'/admin/user/del/' + ${user.id}} + '\');'">Delete</a></td>
				</tr>
			</tbody>
		</table>
	</div>

	<div th:include="common/layout::js"></div>
	<script type="text/javascript">
		/*<![CDATA[*/
           function confirm(message, url) {
      	   		bootbox.confirm(message, function(confirmed) {
                  if (confirmed) {
                	  window.location.href=url;
                  }
             });
			return false;
			}
	           
        /*]]>*/
	</script>
</body>
</html>